package lib

func init() {
	Probs = append(Probs, Problem{
		Num:         300,
		Discription: "最长递增子序列",
		Level:       2,
		Labels: map[string]int{
			"动态规划": 1,
		},
	})
}

func LengthOfLIS(nums []int) int {
	n := len(nums)
	dp := make([]int, n)
	dp[0] = 1
	maxLen := 1
	for i := 1; i < n; i++ {
		//记得每次移动i要初始化dp[i]
		dp[i] = 1
		for j := i - 1; j >= 0; j-- {
			if nums[i] > nums[j] {
				dp[i] = max(dp[i], dp[j]+1)
			}
		}
		maxLen = max(maxLen, dp[i])
	}

	return maxLen
}